package main

import "fmt"

// 数组是值类型
func arrays() {
	var a1 [5]int
	a2 := [3]int{1, 3, 5}
	a3 := [...]int{2, 4, 6}
	var grid [4][5]int
	fmt.Println(a1, a2, a3, grid)

	for _, row := range grid {
		for _, col := range row {
			fmt.Printf("%d ", col)
		}
		fmt.Println()
	}
}

func slices() {
	arr := [...]int{0, 1, 2, 3, 4, 5, 6, 7}

	fmt.Println("arr[2:6] =", arr[2:6])
	fmt.Println("arr[2:] =", arr[2:])
	fmt.Println("arr[:6] =", arr[:6])
	fmt.Println("arr[:] =", arr[:])
}

func main() {
	arrays()
	slices()
}
